tag不存在或已被下架!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cameracontrol : MonoBehaviour
{
GameObject player;
// Start is called before the first frame update
void Start()
{
this.player = GameObject.Find("player");
}
// Update is called once per frame
void Update()
{
Vector3 playerPos = this.player.transform.position;
transform.position = new Vector3(
playerPos.x, playerPos.y, transform.position.z);
}
}
this.player = GameObject.Find("player");先來簡單介紹一下this的用法。"this"代表本身載入的物件,也就是說this.player代表是本身載入的物件所持有的player變數。

